<?php $this->load->view('admin/_begin') ?>
<?php $this->load->view('admin/' . $this->router->fetch_class() . '/_filter') ?>
<form accept-charset="utf-8" method="post" action="<?php echo site_url('admin/'.$this->router->fetch_class() . '/action') ?>">	
  <div id="filter-stage" style="display: block;">	
    <table border="0" class="table-list">
      <thead>
        <tr>
          <th class="align-center" with="30">
            <input type="checkbox" class="check-all" value="" name="action_to_all">
          </th>
          <th><?php echo $this->lang->line("label.state.country_id") ?></th>
          <th><?php echo $this->lang->line("label.state.name") ?></th>
          <th><?php echo $this->lang->line("label.state.lat") ?></th>
          <th><?php echo $this->lang->line("label.state.lng") ?></th>
          <th></th>
        </tr>
      </thead>
      <tbody>
        <?php 
        if(empty($objects)){ ?>
        <tr>
          <td colspan="6">
            <div class="no_data"><?php echo $this->lang->line('label.empty.data', 
                    $this->lang->line('label.'.$this->router->fetch_class().'s'))?></div>
          </td>
        </tr>
        <?php }
        $ref_obj = null;
        $temp = false;
        foreach ($objects as $obj) { 
          if(empty($ref_obj) || $ref_obj['id'] != $obj['country_id']){
            $ref_obj = $this->country_model->get($obj["country_id"]);
            $temp = true;
          } else $temp = false;
          ?>
          <tr>
            <td class="align-center">
              <input type="checkbox" value="<?php echo $obj['id'] ?>" name="action_to[]">
            </td>
            <td>
              <?php              
              if ($ref_obj && $temp ) {
                ?>
                <a href="<?php echo site_url('admin/'."country/show/" . $obj["country_id"]) ?>">
                  <img width="40px" src="<?php echo site_url('admin/file_upload/get_img_from_path?path='.
                     'country/'.$ref_obj['flag_path'])?>" alt="flag_path"/>
                  <?php echo $this->country_model->to_string($ref_obj)?>
                </a>
              <?php } ?>
            </td><td>
              <?php echo $obj["name"] ?>
            </td><td>
              <?php echo $obj["lat"] ?>
            </td><td>
              <?php echo $obj["lng"] ?>
            </td>
            <td class="actions">
              <a class="btn orange edit" href="<?php echo site_url('admin/'.$this->router->fetch_class() . '/edit/' . $obj['id']) ?>">
                <?php echo $this->lang->line('btn.edit') ?>
              </a>
              <a class="confirm btn red delete" href="<?php echo site_url('admin/'.$this->router->fetch_class() . '/delete/' . $obj['id']) ?>"
                 style="margin-left: 5px">
                <?php echo $this->lang->line('btn.delete') ?></a>					
            </td>
          </tr>
        <?php } ?>
      </tbody>
    </table><div class="paging"><?php echo $paging ?></div>
  </div>  
  <div class="table_action_buttons">
    <button class="btn red confirm" value="delete" name="btnAction" type="submit" disabled="disabled">
      <span><?php echo $this->lang->line('btn.delete') ?></span>
    </button>
  </div>
</form>
<?php $this->load->view('admin/_end') ?>